/*
 * Creado el 02/05/2006
 *
 * TODO Para cambiar la plantilla de este archivo generado, vaya a
 * Ventana - Preferencias - Java - Estilo de codigo - Plantillas de codigo
 */
package guru.mercurio.core.delivery.https;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.X509TrustManager;


/**
 * @author sventura
 * 
 * TODO Para cambiar la plantilla de este comentario generado, vaya a Ventana - Preferencias - Java -
 * Estilo de codigo - Plantillas de codigo
 */
public class HttpsX509TrustManager implements X509TrustManager{

    /**
     *  
     */
    public HttpsX509TrustManager() {
        // constructor
        // create/load keystore
        // No need to load the keystore because it will be validated on demand.
        try {
            KeyStore ks = KeyStore.getInstance("JKS");
        } catch (KeyStoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    public void checkClientTrusted(X509Certificate chain[], String authType) throws CertificateException {
        return;
    }

    /**
     * This function is called when receiving information from the server. Before accepting the info
     * it checks that the certificates sent by the server are valid according to this function.
     * 
     * @throws CertificateException
     *             if the certificate does not meet this peer's validation.
     */

    public void checkServerTrusted(X509Certificate oaChain[], String sAuthType) throws CertificateException {
        //special handling such as poping dialog boxes
        //Certificate is valid.
        return;
    }

    /**
     * Returns the valid or accepted issuers. Currently this function returns one empty certificate.
     * The validation is done in checkServerTrusted function.
     */
    public X509Certificate[] getAcceptedIssuers() {
        return new X509Certificate[0];
    }

    public static void main(String[] args) {
    }
}